#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    vector<int> cost(n);
    for (int i = 0; i < n; i++)
        scanf("%d", &cost[i]);

    if (n < 3)  cout << 0;

    vector<int> min_cost(n + 1, 0);
    for (int i = 2; i <= n; i++)
        min_cost[i] = min(cost[i - 1] + min_cost[i - 1], cost[i - 2] + min_cost[i - 2]);

    printf("%d", min_cost[n]);

    return 0;
}
